-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new --style
called header-filesize
and display it by default
#1988
Conversation
de79acb
to
62980ac
Compare
I have not written tests yet, waiting for some feedback on my approach and implementation, I will make necessary changes and then write tests in the final steps |
30a0639
to
7d7c461
Compare
Okay, so I moved the header fields into Example usage:
Note that I also added a deprecation warning for
This has broken a lot of tests, I will address those once I know we agree on the approach. |
6c52de1
to
d57bed2
Compare
src/style.rs
Outdated
@@ -11,6 +11,10 @@ pub enum StyleComponent { | |||
Grid, | |||
Rule, | |||
Header, | |||
Filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so I don't forget: We should consider marking this enum as #[non_exhaustive]
, similar to #2012
I did not have time to review this at all, but dare to ask: would it maybe make sense to keep
Just a suggestion - I haven't thought about it in detail. |
@sharkdp I wouldn't mind that either, that might help by being:
Let's hear what others have to say. |
I actually had |
Okay, I will update the code according to @sharkdp's comment (hopefully tomorrow). Thanks! |
I think this is starting to look good on a high level, so it's soon time to start detailed review. One high-level thing to discuss is what header fields to show by default. Right now all new header fields are shown. I think Size is a reasonable default. Maybe even last modification time. But I'm not sure Permissions is worth showing by default. Especially since bat is read-only. What do you think of skipping showing Permissions by default? I also think we should simplify It would also be neat to align the header field values vertically. But I think it is fine to skip that in the first version of this feature. One thing that might be worth doing in this initial PR is to also mark the other header fields values in bold, and not only the filename. For context, here is current default output of
I also took a look at what impact this PR has on the public API, using a new tool I wrote:
which looks like a reasonable diff. |
@Enselic regarding the default, I prefer Filename and Filesize, leaving the rest to be specified by users if necessary (I rarely look up or use last modified date of files, but I can't say that for everyone). I updated the code to make other component values bold as well. So far then, I only need to write tests, but open to more feedback, too. |
6be7d65
to
61e7f44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here comes another round of comments.
May I also ask you to keep the CI green from now on, and before the next round of review please? Let me know if you have troubles reproducing the failures in CI locally, and I'll help you out.
And thanks a lot for working on this PR!
df1376b
to
3329a8f
Compare
Thanks @Enselic for the review. I went with Option 1, removed permissions and lastmodified, so now it's only filename and size. Let me know if your thoughts. |
I created a ticket where we can discuss this further. If we introduce a new style called I hope we can take care of this in a way that does not cause annoying conflicts for you @mdibaiee. The easiest way to avoid conflicts is probably to create a PR that solves #2061 that is based on this PR. And when that PR is ready, we first merge this PR, and then directly after the other PR. Since we want to have the bat master branch always releasable, it would be wise to wait a bit with merging this, just to play it safe. |
I would be in favor of this (implementing #2061 and keeping |
Okay, so should I just wait then, or is there any action on my side you need? |
Since sharkdp has been clear on that he is OK with this being merged even though having some reservations, I think we should merge it actually. I think we have enough of a plan on how to remove Personally I would have found it useful to have that info in the header by default. E.g. when looking around in rustdoc JSON files that can easily be 7 MB big, it takes several seconds to highlight the entire file. In cases like that, it is useful to be informed of that the file is huge. It makes bat/syntect seem less slow. And when it is not interesting to know the size of a file, it only takes up one line. Another way to look at it is to see it as a proxy for the number of lines in a file, which can also occasionally be useful to know. When navigating in a new repo, it gives a quick indication of a file is interesting to explore further. We can't really print the actual number of lines in a file, since that would requires us to read the entire file up-front. But I am also perfectly fine with if we change our mind and remove Waiting with making it the default is for sure the most low-risk approach. But many of us write code for bat for fun, and it seems a lot more fun to me to merge this PR than to wait. And crucially, it is not prohibitively fun, but reasonably fun. @mdibaiee I just realised we forgot to ask you to add a CHANGELOG.md entry for this change as per https://github.com/sharkdp/bat/blob/master/CONTRIBUTING.md. Could you do that please? |
Co-authored-by: Martin Nordholts <enselic@gmail.com>
Co-authored-by: Martin Nordholts <enselic@gmail.com>
f62f1b1
to
06d38bc
Compare
@Enselic that sounds more fun indeed, thanks! |
I think you accidentally committed changes to submodules in assets/syntaxes/02_Extra |
06d38bc
to
1b121d6
Compare
@sharkdp fixed that, that always confuses me 😁 |
--style
called header-filesize
and display it by default
Big thanks for your contribution @mdibaiee! And thank you for your patience with us :) I think we can add more info in CHANGELOG.md, e.g. mentioning that IMHO we need to fix #2061 before we can add timestamp and file permission info like you originally had in this PR. But I look forward to any future PR that you will create :) Now I will try to give some attention to #1985 that has also been sitting around for a while (sorry about that) |
Fixes #1701